package com.dzl.constant;

import com.dzl.config.ApplicationConfiguration;
import lombok.extern.slf4j.Slf4j;

/**
 * 蓝色兄弟 常量
 * @author WangJian
 * @date 2021/7/13 0013
 */
@Slf4j
public class ApiExtractCardConstant {

    // 直充下单接口
    public static final String DIRECT_URL = getUrl() + "/api/extractCard/makeOrder";
    // 秘钥
    public static final String KEY = getKey();
    // 回调地址
    public static final String NOTIFY_URL = ApplicationConfiguration.getDomain() + "/applet/extractCard/notify";
    // 商户号
    public static final String MERCHANT_ID = getMerchantId();

    /**
     * 获取API地址 正式服or测试服
     * @date 2021/7/14 0014 11:44
     * @author ChenLong
     * @param
     * @return java.lang.String
     */
    public static String getUrl() {
        String isProduct = ApplicationConfiguration.getInstance().getIsProduct();
        if (isProduct == null || "0".equals(isProduct)) {
            log.info("getUrl isProduct: " + isProduct);
            return "http://api.yaajie.com:8080/";
        } else {
            return "http://api.yaajie.com:8080/";
        }
    }

    /**
     * 获取KEY 正式服or测试服
     * @date 2021/7/14 0014 11:44
     * @author ChenLong
     * @param
     * @return java.lang.String
     */
    public static String getKey() {
        String isProduct = ApplicationConfiguration.getInstance().getIsProduct();
        if (isProduct == null || "0".equals(isProduct)) {
            log.info("getKey isProduct: " + isProduct);
            return "nNrK3897pUWmGm8MH1JfAaUfLzhhwR5B";
        } else {
            return "nNrK3897pUWmGm8MH1JfAaUfLzhhwR5B";
        }
    }

    /**
     * 商户号
     * @date 2021/7/30 0030 9:55
     * @author ChenLong
     * @param
     * @return java.lang.Integer
     */
    public static String getMerchantId() {
        String isProduct = ApplicationConfiguration.getInstance().getIsProduct();
        if (isProduct == null || "0".equals(isProduct)) {
            log.info("getMerchantId isProduct: " + isProduct);
            return "M14484";
        } else {
            return "M14484";
        }
    }
}
